package com.study.newjava8.lambda;

import com.study.newjava8.pojo.Employee;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * Lambda基本练习
 * @author huangsm
 * @version V1.0
 */
public class LambdaTest2 {
    public static void main(String[] args) {
        //排序
        List<Employee> employees= Arrays.asList(
                new Employee("huangsm",22,40020.0),
                new Employee("huangsm1",24,52300.0),
                new Employee("huangsm2",26,40100.0),
                new Employee("huangsm3",21,42300.0)
        );
        Collections.sort(employees,(e1,e2)->{
            if (e1.getAge()==e2.getAge()){
                return e1.getName().compareTo(e2.getName());
            }else {
                return Integer.compare(e1.getAge(),e2.getAge());
            }
        });
        employees.forEach(System.out::println);
    }
}
